<template>
	<view class="w100p pr common_wrap bg_black">
		<CommonHeader :title="mainTitle" color="#fff" @goback="goback" backgroundColor="rgba(0,0,0,0)" :is-right="true">
			<view slot="right" @click="shareBtn">
				<uni-icons type="redo-filled" size="44rpx" color="#fff"></uni-icons>
			</view>
		</CommonHeader>
		<view class="w100p flex-item oh">
			<scroll-view scroll-y class="w100p scroll-Y">
				<view class="w100p swiper_video" :style="{top: +statusBarHeight + 44 + 'px'}">
					<swiper class="w100p swiper" :disable-touch="stopTouchMove" :current="swiperCurrent" @change="swiperChange" circular :indicator-dots="showDots"
						indicator-color="#9B969A" indicator-active-color="#fff" circular="true">
						<swiper-item v-if="!!business.video">
							<view class="pr video_wrap">
								<video id="myVideo" class="w100p video_wrap" :src="business.video" 
									:poster="business.bg_img" :show-center-play-btn="false" object-fit="cover"  play-btn-position="center"
									:controls="false" >
								</video>

								<cover-view v-show="isShow" class="pa play_wrap" @click="plays(business.video)">
									<view class="icon_wrap">
										<u-icon name="play-right-fill" color="#fff" size="46"></u-icon>
									</view>
								</cover-view>
								<cover-view v-show="isShow" class="pa history_wrap" v-if="historyList.length">
									<u-notice-bar class="w100p" mode="vertical" :is-circular="false" :volume-icon="false" type="none" :list="historyList" font-size="22"
										duration="5000"></u-notice-bar>
								</cover-view>
							</view>
						</swiper-item>
						<swiper-item v-for="(item, index) in list" :key="index">
							<image class="w100p img" :src="item" mode="aspectFill" @click="amplifyImg(item)"></image>
						</swiper-item>
					</swiper>
					<cover-view v-show="isShow" class="pa history_wrap" v-if="historyList.length">
						<u-notice-bar class="w100p" mode="vertical" :is-circular="false" :volume-icon="false" type="none"
							:list="historyList" font-size="22" duration="5000"></u-notice-bar>
					</cover-view>
				</view>
				<view :style="{marginTop:  400 + 'rpx'}"></view>
				<view class="w100p pr common_content bg_black">
					<view class="w100p merchant_top">
						<view class="w100p flex-box title_01">
							<text>Hello，</text>
							<image class="img" src="@/static/detail/next.png" mode="widthFix" @click="nextSwiper"></image>
						</view>
						<view class="w100p title_02" v-if="lang !== 'ru'">
							{{ $t('欢迎来到') }}{{ business.name || "--" }}	{{ $t('的店铺') }}
						</view>
						<view class="w100p title_02" v-else>
							{{ business.name_ru || "--" }} Магазин
						</view>
						<view class="w100p flex-box major">
							<text class="flex-none name" v-if="lang !== 'ru'">{{ $t('主营') }}:</text>
							<uni-icons type="shop" size="30rpx" color="#fff" v-else></uni-icons>
							<u-notice-bar  :speed="150" class="flex-item" padding="0" :is-circular="true" :volume-icon="false" type="none" :list="[business[plang('desc')]]" font-size="22" color="#fff"
								v-if="business.desc && business.desc.length > 20"></u-notice-bar>
							<text class="flex-item pl-10" :style="langR == 'zh'?'font-size:28rpx':'font-size: 24rpx;'" v-else >{{ business[plang('desc')] }}</text>
						</view>
					</view>
					<view class="w100p pr flex-column merchant_detail">
						<view class="pa flex-box address_wrap">
							<!-- <u-icon class="flex-none name" name="map" color="#fff" size="30"></u-icon> -->
							 <image src="/static/detail/location.png" class="img"></image>
							<u-notice-bar class="flex-item":speed="150"  padding="0" :is-circular="true" :volume-icon="false" type="none" :list="[business[plang('company_address')]]" font-size="22"
								color="#fff" v-if="business.company_address && business.company_address.length > 15"></u-notice-bar>
							<text class="flex-item pl-10" :style="langR == 'zh'?'font-size:28rpx':'font-size: 24rpx;'" v-else>{{ business[plang('company_address')] }}</text>
						</view>
						<view class="w100p flex-none inline-flex detail_wrap">
							<view class="pr merchant_header">
								<view class="oh header_img">
									<image class="img" :src="business.logo || '/static/default.png'" mode="aspectFill" @error="errorDefaul"></image>
								</view>
								<view class="oh header_icon">
									<image class="img" :src="createNational(business.country).imgurl" mode="aspectFill" ></image>
								</view>
							</view>
							<view class="flex-item oh name_wrap">
								<view class="pr shop_name">
									<view class="dot-dian">
										{{ business[plang('name')] || "--" }}
									</view>
									<view class="name-righx">
										<image class=" img" :src="getVipImg(business.isvip)" mode="widthFix"></image>
										<view style="color: #F5C052;font-size: 20rpx;" v-if="business.isvip != 0">vip</view>
									</view>
								
								</view>
								<view class="w100p star_wrap">
									<u-rate :count="5" :current="business.comment_score" inactive-icon="star-fill" inactive-color="#DADADA" active-color="#FFE05F"
										:disabled="true"></u-rate>
								</view>
							</view>
							<view class="flex-none follow_wrap" @click="collectMerchant(true)" v-if="!isCollect">
								+ {{ lang !== 'ru' ? "关注店铺" : "Подписка" }}
							</view>
							<view class="flex-none follow_wrap" @click="collectMerchant(false)" v-else>
								{{ $t("已关注")}}
							</view>
						</view>
						<view class="w100p flex-none flex-box overwiew_wrap">
							<view class="flex-item overwiew_item">
								<view class="name">{{ $t("创立时间") }}</view>
								<view class="con">
									{{ time("S", business.createtime, "date") }}
								</view>
							</view>
							<view class="flex-none segmentation">
								/
							</view>
							<view class="flex-item overwiew_item">
								<view class="name">{{ $t("占地面积") }}</view>
								<view class="con">
									{{ business.zdmj || "--" }}㎡
								</view>
							</view>
							<view class="flex-none segmentation">
								/
							</view>
							<view class="flex-item overwiew_item">
								<view class="name">{{ $t("在职员工") }}</view>
								<view class="con">
									{{ business.employee || "--" }}{{ lang !== 'ru' ? "名" : "чел." }}
								</view>
							</view>
						</view>
						

					</view>
					<view class="box-hezi"> 
						<view class="w100p title">
							{{ $t('店铺简介')}}
						</view>
						<view>
							{{ business[plang('content')] }}
						</view>
					</view>

					<view class="w100p flex-box imglist_wrap">
						<view class="flex-item oh list_wrap" :class="{'ru': lang === 'ru'}">
							<view class="w100p title">
								{{ $t('营业执照') }}
								
							</view>
							<view class="w100p flex-box img_wrap" v-if="licensePic.length">
								<image class="img" :class="{'only_img': licensePic.length == 1}" :src="item" mode="aspectFill" v-for="(item, index) in licensePic" :key="index"
									@click="amplifyImg(item)">
								</image>
							</view>
							<view class="w100p flex-column img_wrap" v-else>
								<image class="no_img" src="@/static/detail/nothing.png" mode="heightFix"></image>
								<text class="noPic">{{ $t("暂无图片") }}</text>
							</view>
						</view>
						<view class="flex-item oh list_wrap" :class="{'ru': lang === 'ru'}">
							<view class="w100p title">
								{{ $t('生产许可') }}
								
							</view>
							<view class="w100p flex-box img_wrap" v-if="!!permitPic.length">
								<image  class="img" :class="{'only_img': permitPic.length == 1}" :src="item" mode="aspectFill" v-for="(item, index) in permitPic" :key="index"
									@click="amplifyImg(item)">
								</image>
							</view>
							<view class="w100p flex-column img_wrap" v-else>
								<image class="no_img" src="@/static/detail/nothing.png" mode="heightFix"></image>
								<text class="noPic">{{ $t("暂无图片") }}</text>
							</view>
						</view>
					</view>
					<template v-if="!!business.vr&&!!vrImglists.length">
						<view class="w100p big_title">
							{{ $t('VR看厂') }}
						
						</view>
						<scroll-view scroll-x class="scrolxxx-wwww">
							<view class="w100p scrolxxx" >
								<image class="goback_img" :src="item" mode="aspectFill" @click="onGo3D(item)" v-for="(item,index) in vrImglists" :key="index"></image>
							</view>
					</scroll-view>

					</template>

					<cover-view class="pa swiper_wrap"></cover-view>
				</view>
				<view class="w100p pr white_bg details_wrap">
					<view class="w100p pr tabs_wrap">
						<u-tabs ref="uTabs" height="50" font-size="24" gutter="26" bg-color="transparent" active-color="#0097FF" inactive-color="#606366" :list="filterList"
							:current="current" @change="tabsChange" :is-scroll="true" bar-height="12"></u-tabs>
					</view>
					<scroll-view class="w100p shop_wrap" scroll-y="true" @scrolltolower="lower" @touchmove.stop>
						<template v-if="!!dataList && !!dataList.length">
							<view class="w100p flex-box list_wrap" v-for="(item, index) in dataList" :key="index">
								<view class="list_item" v-for="subItem in item.shop" :key="subItem.id" @click="goDetails(1, subItem.id, subItem.yj_id,subItem)">
									<view class="w100p img_wrap">
										<image class="img" :src="subItem[plang('pic')] || subItem.pic" mode="aspectFill"></image>
									</view>
									<view class="w100p flex-item con_wrap">
										<view class="w100p list_name">
											{{ subItem[plang('name')] || $t("暂无名称") }}
										</view>
										<view class="w100p flex-box price_wrap">
											<text class="flex-none unit">{{subItem.currency || '￥'}}</text>
											<text class="flex-item ellipsis num">{{ subItem.sell_price || 0 }}</text>
											<view class="flex-none look">
												<uni-icons type="eye" size="28rpx" color="#606366"></uni-icons>
												<text> {{ subItem.viewnum > 100 ? "100+" : subItem.viewnum }}</text>
											</view>
										</view>
										<view class="w100p flex-box shop_wrap" v-if="subItem.merchant">
											<view class="flex-none shop_img">
												<image class="img" :src="subItem.merchant.logo" mode="aspectFill"></image>
											</view>
											<view class="flex-item name_wrap">
												<view class="pr shop_name ellipsis">
													{{ subItem.merchant[plang('name')] || $t("暂无名称") }}
													<image class="pa img" :src="getVipImg(subItem.merchant.isvip)" mode="widthFix"></image>
												</view>
											</view>
											<view class="flex-none country_img">
												<image class="img" :src="createNationalCircle(subItem.merchant.country).imgurl" mode="aspectFill"></image>
											</view>
										</view>
										<view class="w100p flex-box shop_wrap" v-else>
											<view class="flex-none shop_img">
												<image class="img" src="@/static/gluz.png" mode="aspectFill"></image>
											</view>
											<view class="flex-item ellipsis pr shop_name shop_name_01">
												GLUZ
											</view>
										</view>
									</view>
								</view>
								<view class="w100p inline-flex" v-if="!!item.adv && !!item.adv.length">
									<view class="w100p discount_item" v-for="subItem in item.adv" :key="subItem.id" @click="goDetails(1, subItem.id, subItem.yj_id)">
										<view class="w100p pr img_wrap">
											<image class="img" :src="subItem.pic" mode="aspectFill"></image>
											<text class="label" v-if="lang == 'zh'">折扣</text>
											<!-- 俄语 -->
											<text class="label-ru" v-if="lang== 'ru'">СКИДКА</text>
										</view>
										<view class="w100p flex-item con_wrap">
											<view class="w100p list_name">
												{{ subItem[plang('name')] || $t("暂无名称") }}
											</view>
											<view class="w100p flex-box price_wrap">
												<text class="flex-none unit">{{ subItem.currency || '￥' }}</text>
												<text class="flex-item ellipsis num">{{ subItem.sell_price|| 0 }}</text>
												<view class="flex-none look">
													<uni-icons type="eye" size="28rpx" color="#606366"></uni-icons>
													<text> {{ subItem.viewnum > 100 ? "100+" : subItem.viewnum }}</text>
												</view>
											</view>
										</view>
									</view>
								</view>
								<view class="w100p inline-flex swiper_wrap" v-if="!!item.swiper && !!item.swiper.length">
									<u-swiper class="w100p" :list="item.swiper" :effect3d="item.swiper.length !== 1" mode="none" bg-color="transparent"
										@click="clickSwiper(item.swiper, $event)"></u-swiper>
								</view>
							</view>
							<view class="w100p tc pb-20" v-if="isData">
								{{ $t("没有更多了") }}
							</view>
						</template>
						<view v-else class="w100p pr empty_wrap">
							<view class="empty">
								<u-empty :text="$t('数据为空')" mode="list"></u-empty>
							</view>
						</view>
					</scroll-view>
				</view>
			</scroll-view>
		</view>

		<view class="w100p flex-none flex-box shop_bottom" >
			<image class="flex-none img" :src="business.logo || '/static/default.png'" mode="aspectFill" @error="onAvatar"></image>
			<text class="flex-item name">{{ business[plang('fzr_name')] || "--" }}</text>
			<view class="flex-none inline-flex btn_wrap" >
				<view class="flex-none btn_l" @click="goInitiateMeeting">
					{{ $t("发起视频通话") }}
					<image
						src="/static/translatexx.png"
						class="translatexxxxxx"
						mode="widthFix"
					/>
				</view>
				<view class="flex-none btn_r" @click="goTalk">
					{{ $t("聊天") }}
				</view>
			</view>
		</view>

		<!-- 图片放大 -->
		<uni-popup ref="popup" class="common_pop" mask-background-color="rgba(0,0,0,1)">
			<view class="w100p">
				<image class="w100p" :src="commonImg" mode="widthFix" @click="closePop"></image>
			</view>
		</uni-popup>

		<!-- 视频放大 -->
		<uni-popup ref="videoPopup" class="video_pop" @change="editPop" mask-background-color="rgba(0,0,0,1)">
			<view class="w100p">
				<video id="myVideo1" class="w100p video_wrap" ref="myVideo1" :src="commonVideo" @play="playVideo()" @pause="endVideo()" @ended="endVideo()"
					:show-center-play-btn="false" object-fit="cover" @error="videoErrorCallback" play-btn-position="center" :controls="false" @click="stopVideo">
				</video>
			</view>
		</uni-popup>

		<u-mask :show="isShare" @click="closeShare">
			<view class="pa flex-column tc copy_wrap" @click.stop>
				<view class="w100p title">
					{{ $t("分享店铺") }}
				</view>
				<view class="w100p con_wrap">
					<view class="w100p">
						{{ $t("该店铺链接地址") }}
					</view>
					<view class="w100p">
						{{HTTP_SHOPPING_URL}}/ts/#/pages/jump/index?bid={{ this.id }}&type=4
					</view>
				</view>
				<view class="w100p btn_wrap" @click="copyHtml">
					{{ $t('复制链接并用浏览器打开') }}
				</view>
			</view>
		</u-mask>

		<CommonLoading :show="loading"></CommonLoading>
	</view>
</template>

<script>
	import CommonHeader from "../components/common-header.vue";
	import vipImg1 from '@/static/detail/vip_1.png';
	import vipImg2 from '@/static/detail/vip_2.png';
	import vipImg3 from '@/static/detail/vip_3.png';
	import vipImg4 from '@/static/detail/vip_4.png';
	import {  request_minute } from '@/api/basic'
	import { chechkIm } from '@/api/basic'

	import {isLogin,createNational,createNationalCircle} from '@/assets/public';
	import { HTTP_SHOPPING_URL } from '@/config/app';
	import {
		time
	} from "@/assets/public";
	export default {
		components: {
			CommonHeader
		},
		data() {
			return {
				HTTP_SHOPPING_URL,
				mainTitle: "",
				id: "",
				lang: "",
				mobile: "",
				business: {}, // 商家详情
				list: [], // 轮播图片集合
				licensePic: [], // 营业执照
				permitPic: [], // 生产许可
				isShow: true, // 播放按钮是否显示
				stopTouchMove: false, // 轮播是否禁止滑动
				videos: null,
				showDots: true, // 指示点是否显示
				commonImg: "",
				commonVideo: "",
				loading: false,
				isRefresher: false,
				historyList: [], //浏览记录列表
				historyNum: 0,
				swiperCurrent: 0,
				isCollect: false,
				filterList: [{
						name: this.$t("默认"),
						field: "",
					},
					{
						name: this.$t("查看量"),
						field: "viewnum",
					},
					{
						name: this.$t("上新"),
						field: "createtime",
					}
				],
				current: 0,
				dataList: [],
				scrollTop: 0,
				page: 1,
				advPage: 1,
				swiperPage: 1,
				limit: 12,
				isRefresher: false,
				isLoading: false,
				field: "",
				isData: false,
				isShare: false,
				userInfo: {},
				statusBarHeight: 0,
				vrImglists: [],
				statusbottom: 0,

			}
		},
		async onShow() {
			
			this.isMessageGo({
				action: 'setLockOrientation',
				otherParams: {
					setLockOrientation: 'portrait-primary',
				}
			})
		},
		async onLoad(val) {
			this.lang = uni.getStorageSync("lang");
			this.mobile = uni.getStorageSync("mobile");
			this.statusbottom = uni.getStorageSync("statusbottom") || 0;
			this.statusBarHeight =  uni.getStorageSync("statusBarHeight") || 0;

			this.id = val?.bid || "";
			// this.mainTitle = val?.title || "";
			// 获取数据详情
			try {
				const {data} = await this.$u.api.shopping.getBusinessDetail({
					id: val.bid,
				});
				let res = data;
				this.business = res.business;
				this.mainTitle = res.business[this.plang('name')] || "";
				this.isCollect = !!res.business.is_guanzhu;
				this.userInfo = res.user || {};
				if (!!res.business?.pics) {
					this.list = res.business.pics.split(",");
				}
				if (!!res.business?.zhizhao_pics) {
					this.licensePic = res.business.zhizhao_pics.split(",");
				}
				if (!!res.business?.scxk_pics) {
					this.permitPic = res.business.scxk_pics.split(",");
				}

				if (!!res.business?.vr_pic && !!this.business.vr) {
					this.vrImglists = res.business.vr_pic.split(",");
				}
				this.getData();

			} catch (e) {}
		},
		created() {
			this.videos = uni.createVideoContext('myVideo1');
			this.getHistoryData();
		},
		mounted() {

		},
		methods: {
			createNational,
			createNationalCircle,
			time,
			onGo3D() {
				uni.navigateTo({
					url:'/pages/iframe/index?id=' + this.id + '&type=1',
				})
		},
			// 头像
			onAvatar(e) {
				this.business.fzr_avatar = '/static/default.png'
			},
			errorDefaul() {
				this.business.logo = '/static/default.png'
			},
			// 分类切换
			tabsChange(val) {
				if (this.isLoading) return;
				this.page = 1;
				this.isData = false;
				this.current = val;
				this.field = this.filterList[val].field;
				this.getData();
			},
			getVipImg(val) {
				switch (val) {
					case 0:
						return vipImg1;
					case 1:
						return vipImg2;
					case 2:
						return vipImg3;
					case 3:
						return vipImg4;
					default:
						break;
				}
			},
			swiperChange(e) {
				this.swiperCurrent = e.detail.current;
			},
			nextSwiper() {
				let num = this.list.length;
				if (!!this.business.video) num++;
				if (this.swiperCurrent < (num - 1)) {
					this.swiperCurrent++;
				} else {
					this.swiperCurrent = 0;
				}
			},
			// 浏览记录列表
			async getHistoryData() {
				try {
					const {
						data
					} = await this.$u.api.shopping.getMemberHistory({
						id: this.id,
						type: "business",
					});
					this.historyNum = data.member_history_count || 0;
					if (!!data.member_history?.length) {
						let arr = [];
						let avatarList = [];
						data.member_history.map((item, index) => {
							let str = item[this.plang('username')] + this.$t("正在查看");
							arr.push(str)
							if (index < 3) {
								avatarList.push(IMAGE_URL + item.avatar);
							}
						})
						this.historyList = [...arr];
						this.avatarList = [...avatarList];
					}

				} catch (e) {}
			},
			editPop(e) {
				if (!e.show) {
					this.videos.pause();
					this.isShow = true;
					this.stopTouchMove = false;
				}
			},
			// 返回
			goback() {
				uni.navigateBack()
			},
			// 播放视频
			playVideo() {
				this.isShow = false;
				this.stopTouchMove = true;
			},
			// 视频中间播放按钮
			plays(video) {
				this.commonVideo = video;
				this.isShow = false;
				this.stopTouchMove = true;
				this.$refs.videoPopup.open();
				this.$nextTick(() => {
					this.videos.play()
				})
			},
			// 监听视频停止播放
			endVideo() {
				this.isShow = true;
				this.stopTouchMove = false;
			},
			// 停止播放
			stopVideo() {
				this.videos.pause();
				this.isShow = true;
				this.stopTouchMove = false;
				this.$refs.videoPopup.close();
			},
			// 视频错误回调
			videoErrorCallback: function(e) {
				uni.showModal({
					confirmText: this.$t("确定"),
					cancelText: this.$t("取消"),
					content: e.target.errMsg,
					showCancel: false
				})
			},
			// 图片放大
			amplifyImg(imgUrl) {
				if (!imgUrl) return;
				this.commonImg = imgUrl;
				this.$refs.popup.open();
			},
			// 关闭图片弹窗
			closePop() {
				this.$refs.popup.close();
			},
			// 触底加载
			lower() {
				if (this.isRefresher || this.loading) return;
				if (this.isData) return;
				this.page++;
				this.getData();
			},
			// 关注
			async collectMerchant(val) {
			
				try {
					const res = await this.$u.api.shopping.addfavorite({
						bid: this.id,
						is_guanzhu: 1,
					});
					uni.showToast({
						title: res[this.plang('msg')],
						icon: 'none',
						duration: 2000
					});
					this.isCollect = val;
				} catch (e) {}
			},
			// 获取列表
			async getData() {
				if (this.isLoading) return;
				this.isLoading = true;
				try {
					const {
						data
					} = await this.$u.api.shopping.getDataList({
						id: this.id,
						st: 0,
						pagenum: this.page,
						field: this.field,
						pagesize: 24,
					});
					// 首页置空数据
					if (this.page === 1) {
						this.dataList = [];
					}
					// 每页最多12条数据，分两组
					if (!!data?.length) {
						// 每6条数据加一组广告
						let obj = {
							shop: [],
							adv: [],
							swiper: [],
						};
						let obj1 = {
							shop: [],
							adv: [],
							swiper: [],
						};
						data.map((item, index) => {
							if (index < 12) {
								obj.shop.push(item);
							} else {
								obj1.shop.push(item);
							}
						})

						let advRes = [];
						let swiperRes = [];
						// 大于6条，加载广告
						if (data.length > 0) {
							advRes = await this.$u.api.shopping.getDataList({
								id: this.id,
								st: 0,
								pagenum: this.advPage,
								field: "",
								gid: 4,
								pagesize: 6,
							});
							swiperRes = await this.$u.api.shopping.getpllist({
								pagenum: this.swiperPage,
								bid: this.id,
								pagesize: 10,
								tfwz: 1,
							});
						}

						if (!!advRes?.data?.length) {
							advRes.data.map((item, index) => {
								if (index < 3) {
									obj.adv.push(item);
								} else {
									obj1.adv.push(item);
								}
							})
						}
						if (!advRes?.data?.length || advRes.data.length < 6) this.advPage = 1;

						if (!!swiperRes?.data?.length) {
							let num = 0;
							swiperRes.data.map((item, index) => {
								if (!item.pic) return;
								let subObj = {
									image: item[this.plang('pic')],
									...item
								}
								if (num < 6) {
									obj.swiper.push(subObj);
								} else {
									obj1.swiper.push(subObj);
								}
								num++;
							})
						}
						if (!swiperRes?.data?.length || swiperRes.data.length < 6) this.swiperPage = 1;

						this.dataList.push(obj);

						if (data.length > 12) this.dataList.push(obj1);


						// 数据不足12条，禁止上拉加载
						if (data.length < 24) {
							this.isData = true;
						}
					} else {
						this.isData = true;
					}
					this.isLoading = false;
					this.isRefresher = false;
				} catch (e) {
					this.isLoading = false;
					this.isRefresher = false;
				}
			},
			// 随心问
			goTalk() {
				if (isLogin()) {
					if(uni.getStorageSync("user_id") == this.business.mid) {
						uni.showToast({
							title: this.$t('不能和自己聊天'),
							icon: "none",
						});
					} else {
						this.isMessageGo({
							action: 'initiateChat',
							data: this.business.mid
						})
						return;
						chechkIm({
							send_uid: uni.getStorageSync("user_id"),
							receive_uid: this.business.mid,
						}).then(res => {
							if (res.data.code == 1) {
								this.isMessageGo({
									action: 'initiateChat',
									data: this.business.mid
								})
							} else {
								if (res.data.data.send_user == false) {
									uni.$u.toast(this.$t('积分不足，请充值积分'))
									setTimeout(() => {
										uni.navigateTo({
											url: '/pages/vip/scorePoint',
										})
									}, 500)
								} else {
									uni.$u.toast(this.$t('对方积分不足'))
								}
							}
						})
					}

					// this.isMessageGo({
					// 	action: 'initiateChat',
					// 	data: this.business.mid
					// })
				}
		
			},
			// 发起视频通话
			goInitiateMeeting() {
				if (isLogin()) {
					if(uni.getStorageSync("user_id") == this.business.mid) {
						uni.showToast({
							title: '不能给自己打电话',
							icon: "none",
						});
					} else {
						request_minute({
							user_id: uni.getStorageSync("user_id"),
							target_id: this.business.mid, // type 1是需要翻译 2不需要翻译
						}).then(res => {
							if (res.data.data.flag == 1) {
								this.isMessageGo({
									action: 'call',
									data: {
										userId: this.business.mid,
										type: res.data.data.type || 1,
									}
								})
							} else {
								uni.showToast({
									title: this.$t('积分不足，请充值积分'),
									icon: "none",
								});
								setTimeout(() => {
									uni.navigateTo({
										url: '/pages/vip/scorePoint',
										webview: 'zWebView'
									})
								}, 500)
							}
						})
					}
				
				
				}
			
			},
			// 跳转详情页
			async goDetails(val, id, cid,subItem) {
				if(subItem.offerId) {
					if (!id) {
						let res = await this.$u.api.shopping.addproduct({
							offerId: subItem.offerId,
							name: subItem.subject,
						});
						id = res.data.aid;
					}
					uni.navigateTo({
						url: '/pages/details/shopDetail1688?id=' + id + '&offerId=' + (subItem.offerId || '') + '&offer_price=' + (subItem.sell_price || '')
					})
					return;
				}

				switch (val) {
					case 1:
						if (cid == 'xxxxxxxxxxxxx') {
							uni.navigateTo({
								url: '/pages/details/carDetail?id=' + id
							})
						} else {
							uni.navigateTo({
								url: '/pages/details/shopDetail?id=' + id
							})
						}
						break;
					case 2:
						uni.navigateTo({
							url: '/pages/details/merchantDetail?bid=' + id
						})
						break;
					default:
						break;
				}
			},
			// 分享
			shareBtn() {
				this.isShare = true;
			},
			// 关闭分享
			closeShare() {
				this.isShare = false;
			},
			copyHtml() {
				uni.setClipboardData({
					data: `${HTTP_SHOPPING_URL}/ts/#/pages/jump/index?bid=${ this.id }&type=4`, //要被复制的内容
					success: () => {
						uni.showToast({
							title: this.$t("复制成功")
						})
						this.isShare = false;
					}
				});
			},
			clickSwiper(item, i) {
				if (!item[i]) return;
				if (item[i].yj_id == 'xxxxxxxxxxxxx') {
					uni.navigateTo({
						url: '/pages/details/carDetail?id=' + item[i].url_id
					})
				} else {
					uni.navigateTo({
						url: '/pages/details/shopDetail?id=' + item[i].url_id
					})
				}
			},
		}
	}
</script>

<style scoped lang="less">
	@import "./merchantDetail.less";
	.shop_bottom {
		padding-bottom:calc(env(safe-area-inset-bottom) + 14rpx) ; 
	}
</style>